<%--
 *  File:   DefaultTaskCondition.jsp
 *  Author: David Zhang 
 *  Date:   2002/02/21
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //Initial parameters.
  Category cat = Category.getInstance("jsp.DefaultTaskEdit"); 
  String strModuleName = "BIEE";  
  String strTableName = "ovdefaulttaskcondition";
	String privilegeCode = "Z0704,L601";
%>



<%
  //Get userinfo from session.
  HashMap mapUserInfo = (HashMap) session.getAttribute("userinfo");
%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title>DefaultTaskCondition</title>
<PageFlow:CheckPageFlow pageName="defaulttaskcondition"/>
<%@ include file="/inc/InitEdit.inc" %>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
  <script language="JavaScript" src="../js/FuncLib.js"></script>
  
<%
  Vector defaulttaskconditioninfo = (Vector) pageContext.getAttribute("defaulttaskconditioninfo");
  if ( defaulttaskconditioninfo == null )  defaulttaskconditioninfo = new Vector();
  String defaulttaskid = request.getParameter("defaulttaskid");
  if ( defaulttaskid == null )  defaulttaskid = 
      ((Integer) pageContext.getAttribute("defaulttaskid")).toString();
  
  cat.debug("The defaulttaskid is :" + defaulttaskid); 
  cat.debug("The defaulttaskconditioninfo is :" + defaulttaskconditioninfo);
%>

<script language="JavaScript">
function refreshWindow()
{
  parent.down.location.href = 
    "DefaultTaskCondition.jsp?<%= OvalTools.randomURL() %>&defaulttaskid=<%=JspHelper.filterNull( defaulttaskid )%>&languagecode=<%= strLanguageCode %>" ;
}

function clickCheckbox(j, conditionId)
{
   var frm = document.defaulttaskconditionform;
   if ( ! frm.removeconditions0.length > 0 )
   {
       if ( frm.removeconditions0.checked == true )  
           frm.removeconditions.value = conditionId;
       else  frm.removeconditions.value = -1;
   }
   else
   {
       if ( frm.removeconditions0[j].checked == true )  
           frm.removeconditions[j].value = conditionId;
       else  frm.removeconditions[j].value = -1;
   }
}

function condition_delete()
{
   var frm = document.defaulttaskconditionform;

   <%--[SCRIPT]  Check if some items have been selected.  [SCRIPT]--%>
   var value = "";
   if ( typeof(frm.removeconditions0) != "undefined" )
   {
       if ( ! frm.removeconditions0.length > 0 )
       {
           if ( frm.removeconditions0.checked == true )  value = "true";
       }
       else
       {
          for (var i = 0; i <  frm.removeconditions0.length; i++)
          {
              if ( frm.removeconditions0[i].checked == true )
              {
                  value = "true";
                  break;
              }
          }
       }
   }
   if ( value == "" )
   {
       alert("<%= message.getMessage("MUST_SELECT_ONE_RECORD_TO_DEL")%>");
       return;
   }
  
   <%--[SCRIPT]  Check if the decision is made up.  [SCRIPT]--%>
   if ( ! confirm("<%= message.getMessage("ARE_YOU_SURE_DEL")%>") )  return;
  
   frm.actionname.value = "remove";
   isRunning = true;
   frm.submit();
}
</script>  
</head>
<body>
<form name="defaulttaskconditionform" method="post" action="../Dispatcher"  target="down">
    <input type="hidden" name="pagename" value="defaulttaskcondition">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <input type="hidden" name="orgid" value="<%=JspHelper.filterNull( mapUserInfo.get("orgid") )%>">   
    <input type="hidden" name="defaulttaskid" value="<%=JspHelper.filterNull( defaulttaskid )%>">      
     
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr> 
    <td> 
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td colspan="2" class="summary_top"></td>
        </tr>
        <tr> 
          <td colspan="2"><img src="../images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
            <%= label.getLabelName("L_AddDelCondition") + label.getLabelName("L_Colon") %>
          </td>
        </tr>
      </table>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
          <tr class="deepblue-left"> 
          <td class="title_center" width="22">&nbsp;</td>
          <td class="title_center"           ><%= label.getLabelName("L_ConditionCode") %></td>
          <td class="title_center"           ><%= label.getLabelName("L_ConditionType") %></td>
          <td class="title_center" colspan="3"><%= label.getLabelName("L_ConditionDesc") %></td>
        </tr>
     <% int j = 0;
        String strClassType = ""; 
        //Integer nDefaultTaskId = new Integer(-1);               
        //boolean bHasChecked = false;
        HashMap mapCondition = new HashMap();
        String strConditionId = "";
     %>
        <logic:iterate id="conditioninfo" collection="<%= defaulttaskconditioninfo %>">                      
        <% 
           mapCondition = (HashMap) pageContext.getAttribute("conditioninfo"); 
           strConditionId = ((Integer) mapCondition.get("defaulttaskconditionid")).toString();

           if ( j % 2 == 1 )  strClassType = "td-listrom";      
           else  strClassType = "";
           j++; 
         %>
        <tr  class="<%=JspHelper.filterNull( strClassType )%>" onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'">
          <td width="22"> 
            <input type="checkbox" name="removeconditions0"  class="normalradio" 
                   onClick="javascript:clickCheckbox('<%=JspHelper.filterNull( j - 1 )%>', '<%=JspHelper.filterNull( strConditionId )%>')">
          </td>
          <input type=hidden name=removeconditions value="-1">
          
          <td>&nbsp;<%=JspHelper.filterNull( mapCondition.get("conditioncode") )%></td>
          <td>&nbsp;<%=JspHelper.filterNull( mapCondition.get("conditiontypename") )%></td>
          <td colspan="3">&nbsp;<%=JspHelper.filterNull( mapCondition.get("conditiondesc") )%></td>
        </tr>
        </logic:iterate>
      </table>
    </td>
  </tr>
  <tr><td class="summary_top"></td></tr>
  <tr> 
    <td class="td_center">
    <%--  if (!"false".equals(pageContext.getAttribute("successflag"))){--%>
      <a onclick="popup('DefaultTaskConditionAdd.jsp?<%= OvalTools.randomURL() %>&defaulttaskid=<%=JspHelper.filterNull( defaulttaskid )%>&languagecode=<%= strLanguageCode %>','newwindow','height=220, width=650,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no')"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
      <a onclick="condition_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a></td>
    <%--}--%>
  </tr>
</table>
</from>
</body>
</html>


